package week_02;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class SubSets_78 {
    private List<List<Integer>> ans;
    private List<Integer> subset;
    private int n;

    public List<List<Integer>> subsets(int[] nums) {
        //输入：nums = [1,2,3]
        //输出：[[],[1],[2],[1,2],[3],[1,3],[2,3],[1,2,3]]
        n =nums.length;
        ans =new ArrayList<>();
        subset=new ArrayList<>();
        int cur=0;
        clac(nums,cur);
        return ans;
    }

    public void clac(int[] nums,int cur){
        System.out.println(cur);
        if(cur==n){
            ans.add(new ArrayList<>(subset));
            return ;
        }
        //不加这个数
        clac(nums,cur+1);
        //加这个数
        subset.add(nums[cur]);
        clac(nums,cur+1);
        subset.remove(subset.size()-1);
    }

}
